// JobType2.cpp: implementation of the CJobType2 class.
//Author : Pradeep K Sahu
//Email : sahupk@yahoo.com
//Date  :29-Mar-2003
//Note   : You are free to use the code, and modify. Provided you
//         don't remove this comments. It will be great if you can provide
//		   your feedback.
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "JobQ.h"
#include "JobType2.h"
#include "JobQDlg.h"
#include "PrgDlg.h"
#include "PrgUIThread.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


CJobType2::CJobType2()
{

}

CJobType2::~CJobType2()
{
	CJobQApp *pApp =(CJobQApp *) AfxGetApp();
	((CJobQDlg *) pApp->m_pMainWnd)->Refresh();
}

void CJobType2::execute()
{		
	CPrgUIThread* pTh =(CPrgUIThread *) AfxBeginThread(RUNTIME_CLASS(CPrgUIThread));
	pTh->m_ExecuterID = this->getID();
	Sleep(200);//This is required for initializing the Dialog
	CPrgDlg *pDlg = (CPrgDlg *)pTh->m_pMainWnd;
		pTh->m_pMainWnd->SetWindowText("Job Type 2 is running.....");
	pDlg->m_prgBar.SetRange(0,100);
	//Post message here to update the message..
	while(pDlg->m_prgBar.GetPos() <100)
	{
		pDlg->m_prgBar.SetPos(pDlg->m_prgBar.GetPos()+1);
		Sleep(160);
	}
	pDlg->PostMessage(WM_CLOSE);	
}
